/*
 * @Author: YuA
 * @Date: 2021-07-31 12:48:40
 * @LastEditTime: 2021-08-20 00:12:29
 * @FilePath: \index\src\router\index.js
 */
import Vue from "vue";
import VueRouter from "vue-router";
import Login from "views/login/Login.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    redirect: "/login"
  },
  {
    path: "/login",
    name: "Login",
    component: Login
    // beforeEnter: (to, from, next) => {
    //   if (localStorage.getItem("id") != "") {
    //     next("/home");
    //   }
    // }
  },
  {
    path: "/home",
    name: "Home",
    component: () =>
      import(/* webpackChunkName: "about" */ "views/home/Home.vue")
  },
  {
    path: "/podcast",
    name: "Podcast",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ "views/podcast/Podcast.vue")
  },
  {
    path: "/my",
    name: "My",
    component: () =>
      import(/* webpackChunkName: "about" */ "views/profile/My.vue")
  },
  {
    path: "/song",
    name: "SongRoom",
    component: () =>
      import(/* webpackChunkName: "about" */ "views/song/SongRoom.vue")
  },
  {
    path: "/spruce",
    name: "Spruce",
    component: () =>
      import(/* webpackChunkName: "about" */ "views/spruce/Spruce.vue")
  }
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes
});

export default router;
